package com.example.administrator.myapplication;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

/**
 * Created by Administrator on 2016/3/18 0018.
 */
public class GalleryAdapter extends BaseAdapter{
    private int[] mImgId;
    private Context context;
    public GalleryAdapter(int[] imgId,Context context) {
        this.mImgId = imgId;
        this.context = context;
    }

    @Override
    public int getCount() {
        return mImgId.length;
    }

    @Override
    public Object getItem(int position) {
        return mImgId[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView = new ImageView(context);
        imageView.setImageResource(mImgId[position]);
        return imageView;
    }

}
